<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div{
                padding-top: 20px;
    
            }
            table{
                width: 100%;
                /* height: 100%; */
                 border: 1px solid #000;
                border-collapse: collapse;
                empty-cells: show;
             }
             tr{
                 text-align: center;
             }
             td{
                border: 1px solid #000;
             }
         </style>
</head>

<body>
    <input type="text" placeholder="输入行数" id="tex1">
    <input type="text" placeholder="输入列数" id="tex2">
    <input type="button" value="生成表格" id="btn">
    <div id="table"></div>
    <!-- <a href=""></a> -->
    <!-- <table>
        <tr>
            <td>

            </td>
        </tr>
    </table> -->
</body>
<script>
    //通过拼接方式，实现表格的生成；
    var btn = document.getElementById('btn');
    function list(n1, n2) {
        n1 = n1 * 1;
        n2 = n2 * 1;
        var str = '<table>';
        for (var i = 1; i <= n1; i++) {
            if (i % 2 == 0) {//隔行变色；
                str += '<tr style="background: #ccc;">';
            } else {
                str += '<tr style="background: #fff;">';
            }
            str += '<td>' + i + '</td>';
            for (var j = 1; j <= n2; j++) {
                str += '<td>第' + n1 + '行第' + n2 + '列' + '</td>';
            }
            str += '<td>' + '<a href="">删除</a>' + '</td>';
            str += '</tr>';
        }
        str += '</table>';
        return str;
    }

    btn.onclick = function () {
        var tex1 = document.getElementById('tex1').value;
        var tex2 = document.getElementById('tex2').value;
        var table = document.getElementById('table');
        var a = list(tex1, tex2);
        table.innerHTML = a;
    }
</script>

</html>